#ifndef T32_H264_LIVE_SOURCE_HH
#define T32_H264_LIVE_SOURCE_HH

#include <FramedSource.hh>

extern "C" {
#include "../buffer/ringfifo.h"
}

class T32H264LiveSource : public FramedSource {
public:
    static T32H264LiveSource* createNew(UsageEnvironment& env);
    void signalNewFrame();

protected:
    explicit T32H264LiveSource(UsageEnvironment& env);
    ~T32H264LiveSource() override;

private:
    void doGetNextFrame() override;
    void doStopGettingFrames() override;
    unsigned maxFrameSize() const override;

    static void deliverFrame0(void* clientData);
    void deliverFrame();
    void scheduleNextTick(unsigned microseconds);
    void cancelNextTick();

private:
    EventTriggerId fEventTriggerId;
    TaskToken fTaskToken;
    static constexpr unsigned kMaxFrameBytes = 512 * 1024;
};

#endif // T32_H264_LIVE_SOURCE_HH
